// pages/orderview/index.js
const app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    num:1,
    price:0,
    total_price: 0,
    spotid:0,
    suitid: 0,
    select_date:'',
    linkman: '',
    linkphone: '',
    sub_but:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {    
    this.setData({
      spotid: options.spotid,
      suitid: options.suitid
    });   
    //获取当天或最近一天信息
    var that = this;   
    wx.request({
      url: app.globalData.host + 'api/spot/now_price',
      method: 'POST',
      data: {
        user_id: '4',
        secret_key: '123456',
        body:{
          spot_id: options.spotid,
          suit_id: options.suitid
        }        
      },
      success: function (e) {        
        that.setData({
          price: e.data.body.adultdistributionprice,
          total_price: e.data.body.adultdistributionprice,
          select_date: e.data.body.fulldate
        })
      }
    });    
  },
  subNum: function (options) {
    if (this.data.num > 1){
      this.setData({
        num: this.data.num - 1,
        total_price: Number(this.data.total_price) - Number(this.data.price)
      });
    }
  },
  addNum: function(options) {
    this.setData({ 
      num:this.data.num+1,
      total_price: Number(this.data.total_price) + Number(this.data.price)
    }); 
  },
  toChooseDate: function(options) {
    wx.navigateTo({
      url: '/pages/choosedate/index?ptype=spot&spotid=' + this.data.spotid + '&suitid=' + this.data.suitid,
    })
  },
  linkman: function(e){    
    this.setData({linkman:e.detail.value});
  },
  linkphone: function (e) {
    this.setData({ linkphone: e.detail.value });
  },
  btn: function(options) {
    console.log(this.data);
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})